#pragma once
#include "BinaryReader.h"
#include "util.h"
#include "DAEMatrix.h"
#include "semantic.h"

class VertexList;
class IndexedGeometry;
class ObjMesh;
class MeshList;
class Material;

namespace gmf{
	/**
	* Reads a leadwerks GMF file
	* @author Koen Samyn
	*/
	class GMFReader: public BinaryReader
	{
	public:
		/**
		* Creates a new GMFReader object.
		* @param filename the filename to read.
		*/
		GMFReader(tstring filename);
		/**
		* Destroys the GMFReader.
		*/
		virtual ~GMFReader(void);
		/**
		* Reads the file.
		* @return true if the file was read succesfully, false otherwise.
		*/
		bool Read();
		/**
		* Gets the mesh in this file.
		* @return the ObjMesh object.
		*/
		MeshList* GetMesh(){
			return m_pMeshList;
		}
	private:
		bool ReadGMFMesh();
		bool ReadGMFProperties();
		bool ReadGMFFile();
		bool ReadGMFSurface();
		bool ReadGMFAnimationKeys();
		bool ReadGMFBone();
		bool ReadGMFVertexArray();
		void ReadGMFPositionData(int nrOfVertices,int nrOfElements);
		void ReadGMFNormalData(int nrOfVertices,int nrOfElements);
		void ReadGMFTexCoordData(int nrOfVertices,int nrOfElements);
		bool ReadGMFIndexArray();
		void ReadGMFSemanticData(SEMANTIC semantic,int dataType,int nrOfVertices,int nrOfElements);
		void SkipGMFSemanticData(SEMANTIC semantic,int dataType,int nrOfVertices,int nrOfElements);
		DAEMatrix ReadMatrix();
		/**
		* The mesh list with the list of meshes.
		*/
		VertexList* m_pVertexList;
		/**
		* The indexedgeometry list.
		*/
		IndexedGeometry* m_pIndices;
		/**
		* The list of meshes in the file.
		*/
		MeshList* m_pMeshList;
		/**
		* The current mesh object.
		*/
		ObjMesh* m_pCurrentMesh;
		/**
		* The current material
		*/
		Material* m_pCurrentMaterial;
		/**
		* The transform for the mesh.
		*/
		DAEMatrix m_Transform;

		int m_NrOfObjects;

		// -------------------------
		// Disabling default copy constructor and default assignment operator.
		// If you get a linker error from one of these functions, your class is internally trying to use them. This is
		// an error in your class, these declarations are deliberately made without implementation because they should never be used.
		// -------------------------
		GMFReader(const GMFReader& t);
		GMFReader& operator=(const GMFReader& t);
	};
}